<?php
/**
 * @ClassName: Transaction
 * @Description: 订单交易记录
 * @author: gydtrade
 * @Date: 2024-09-08 10:53
 * @Version: V1.0.0
 */

namespace app\common\model;

use think\Model;
use think\model\concern\SoftDelete;

class Transaction extends Model
{
    use SoftDelete;

    protected $name = 'transaction';
    protected $autoWriteTimestamp = 'dateTime';

    /**
     * 说明: 定义反向关联, 关联至用户表
     * @return \think\model\relation\BelongsTo
     */
    public function member()
    {
        return $this->belongsTo(Member::class, 'member_id');
    }

    /**
     * 说明: 定义反向关联, 关联至订单表
     * @return Transaction|\think\model\relation\HasOne
     */
    public function order()
    {
        return $this->hasOne(ShopOrder::class, 'order_sn', 'trade_no');
    }

}